No need to cram it in the same file as the main window.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <menu id="appmenu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
<gresources>
<gresource prefix="/ui">
<file preprocess="xml-stripblanks">main.ui</file>
+ <file preprocess="xml-stripblanks">appmenu.ui</file>
</gresource>
<gresource prefix="/application_demo">
<file>application.c</file>
gchar *ids[] = { "appmenu", NULL };
builder = gtk_builder_new ();
- gtk_builder_add_objects_from_resource (builder, "/ui/main.ui", ids, NULL);
+ gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <menu id="appmenu">
- <section>
- <item>
- <attribute name="label" translatable="yes">About</attribute>
- <attribute name="action">app.about</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Quit</attribute>
- <attribute name="action">app.quit</attribute>
- <attribute name="accel"><Primary>q</attribute>
- </item>
- </section>
- </menu>
<object class="GtkTreeStore" id="treestore">
<columns>
<!-- column-name NAME -->